/**
 * 数组A，两种操作，最多选一种操作一次：
 * x是[1...N]任意数
 * 1. ai += x
 * 2. ai *= x
 * 因为ai均为正数，显然贪心，选Amax，然后看+N与*N哪个大即可
 */
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;

using llt = long long;
using vi = vector<int>;
using vll = vector<llt>;

int N;
vll A;
llt proc(){
    llt sum = accumulate(A.begin(), A.end(), 0LL);
    llt ans = sum + N;
    llt mmx = *max_element(A.begin(), A.end());
    return max(ans, sum + mmx * (N - 1LL));
}
void work(){
    cin >> N;
    A.assign(N, {});
    for(auto & i : A) cin >> i;
    cout << proc() << endl;
    return;
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int nofkase = 1;
    // cin >> nofkase;
    while(nofkase--) work();
    return 0;
}